package com.geovis.emergency.spd.entity.pc.pojo.vo;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.geovis.emergency.spd.entity.system.entity.SystemDept;
import com.geovis.emergency.spd.entity.system.pojo.vo.SystemDeptTreeVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

/**
 * 配置方案，组织机构树
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SystemDeptVo extends SystemDept {
    @ApiModelProperty(value = "是否是叶子节点(0-不是，1-是)")
    private Integer leaf =1;

    public static SystemDeptVo fromSystemDept(SystemDept dept,Integer leaf)
    {
        if(dept==null)
        {
            return null;
        }
        SystemDeptVo deptVo=new SystemDeptVo();
        BeanUtils.copyProperties(dept,deptVo);
        deptVo.setLeaf(leaf);
        return deptVo;
    }

    public static SystemDeptVo fromSystemDeptTreeVo(SystemDeptTreeVO treeVO)
    {
        SystemDeptVo deptVo=new SystemDeptVo();
        BeanUtils.copyProperties(treeVO,deptVo);
        if(treeVO.getHasChildren())
        {
            deptVo.setLeaf(0);
        }
        return deptVo;
    }
}
